//
//  UUNotificationModel.m
//  UUCharterSupplier
//
//  Created by ZhangAo on 05/03/2018.
//  Copyright © 2018 UUCharter. All rights reserved.
//

#import "UUNotificationModel.h"

@implementation UUNotificationContentModel

- (instancetype)initWithData:(id)data {
    if (![[self class] isEqual:[UUNotificationContentModel class]]) {
        return [super initWithData:data];
    }
    
    UUNotificationContentType contentType = [data[@"type"] integerValue];
    Class contentClass = nil;
    switch (contentType) {
        case UUNotificationContentTypeIntentPlatform:
            contentClass = [UUNotificationContentPlatformModel class];
            break;
        case UUNotificationContentTypeIntentOrder:
            contentClass = [UUNotificationContentIntentOrderModel class];
            break;
        case UUNotificationContentTypeOrderConfirm:
        case UUNotificationContentTypeOrderCancel:
            contentClass = [UUNotificationContentOrderConfirmModel class];
            break;
        case UUNotificationContentTypeCommission:
            DKAssert(0);
        case UUNotificationContentTypeOrderAssign:
        case UUNotificationContentTypeOrderService:
            contentClass = [UUNotificationContentOrderServiceModel class];
            break;
        case UUNotificationContentTypeProductReviewFailure:
            contentClass = [UUNotificationContentProductAuditFailtureModel class];
            break;
        case UUNotificationContentTypeProductReviewSuccess:
            contentClass = [UUNotificationContentProductAuditPassModel class];
            break;
        case UUNotificationContentTypeCarReviewFailure:
            contentClass = [UUNotificationContentCarAuditFailtureModel class];
            break;
        case UUNotificationContentTypeCarReviewSuccess:
            contentClass = [UUNotificationContentCarAuditPassModel class];
            break;
        case UUNotificationContentTypeWithdrawFailure:
            contentClass = [UUNotificationContentWithdrawFailureModel class];
            break;
        case UUNotificationContentTypeWithdrawSuccess:
            contentClass = [UUNotificationContentWithdrawSuccessModel class];
            break;
        case UUNotificationContentTypeKeeperUnregister:
            contentClass = [UUNotificationContentKeeperLogoutModel class];
            break;
        case UUNotificationContentTypeSupplierReviewFailure:
            contentClass = [UUNotificationContentSupplierReviewFailureModel class];
            break;
        case UUNotificationContentTypeSupplierReviewSuccess:
            contentClass = [UUNotificationContentBlank class];
            break;
        default:
            DKAssert(0);
    }
    
    return [[contentClass alloc] initWithData:data];
}

@end

@implementation UUNotificationContentBlank

@end

@implementation UUNotificationContentIntentOrderModel

- (void)setArrival:(NSString *)arrival {
    _arrival = [UUAddressModel addressWithJSON:arrival];
}

- (void)setDeparture:(NSString *)departure {
    _departure = [UUAddressModel addressWithJSON:departure];
}

@end

@implementation UUNotificationContentOrderConfirmModel

- (void)setDeparture:(NSString *)departure {
    _departure = [UUAddressModel addressWithJSON:departure];
}

- (void)setArrival:(NSString *)arrival {
    _arrival = [UUAddressModel addressWithJSON:arrival];
}

@end

@implementation UUNotificationContentOrderServiceModel

- (void)setDeparture:(NSString *)departure {
    _departure = [UUAddressModel addressWithJSON:departure];
}

@end

@implementation UUNotificationContentWithdrawSuccessModel

- (instancetype)init {
    self = [super init];
    if (self) {
        [self addManualMappingDict:@{
                                     @"id" : @"recordId"
                                     }];
    }
    return self;
}

@end

@implementation UUNotificationContentWithdrawFailureModel

@end

@implementation UUNotificationContentProductAuditPassModel

- (instancetype)init {
    self = [super init];
    if (self) {
        [self addManualMappingDict:@{
                                     @"id" : @"productId"
                                     }];
    }
    return self;
}

@end

@implementation UUNotificationContentProductAuditFailtureModel

@end

@implementation UUNotificationContentCarAuditPassModel

- (instancetype)init {
    self = [super init];
    if (self) {
        [self addManualMappingDict:@{
                                     @"id" : @"carId"
                                     }];
    }
    return self;
}

@end

@implementation UUNotificationContentCarAuditFailtureModel

@end

@implementation UUNotificationContentKeeperLogoutModel

@end

@implementation UUNotificationContentPlatformModel

- (instancetype)init {
    self = [super init];
    if (self) {
        [self addManualMappingDict:@{
                                     @"url" : @"URLString"
                                     }];
    }
    return self;
}

@end

@implementation UUNotificationContentSupplierReviewFailureModel

@end

@implementation UUNotificationModel

@end
